﻿package mortal.game.scene3D.player.info
{
    import Message.BroadCast.*;
    import Message.Public.*;
    import com.gengine.debug.*;
    import com.gengine.global.*;
    import extend.language.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.scene3D.ai.*;
    import mortal.game.scene3D.layer3D.utils.*;
    import mortal.game.utils.*;
    import mortal.mvc.core.*;

    public class RoleEntityInfo extends EntityInfo
    {
        private var _serverSpeed:int;
        private var _testSpeed:int;
        private var _isCanControlWalk:Boolean = true;

        public function RoleEntityInfo()
        {
            return;
        }// end function

        override public function updateIsInRoleGroup() : void
        {
            Cache.instance.entity.updateAllIsInRoleGroup();
            return;
        }// end function

        override public function updateIsInRoleGuild() : void
        {
            Cache.instance.entity.updateAllIsInRoleGuild();
            return;
        }// end function

        override protected function updateCamp(param1:int) : void
        {
            super.updateCamp(param1);
            ThingUtil.isNameChange = true;
            return;
        }// end function

        override protected function updateForce(param1:int) : void
        {
            super.updateForce(param1);
            ThingUtil.isNameChange = true;
            return;
        }// end function

        override public function updateZazenEntityId(param1:SEntityId) : void
        {
            super.updateZazenEntityId(param1);
            ThingUtil.isEntitySort = true;
            return;
        }// end function

        override public function updateFighting(param1:Boolean, param2:int) : void
        {
            super.updateFighting(param1, param2);
            if (!param1)
            {
                this.dispatchEvent(new EntityInfoEvent(EntityInfoEventName.RoleOutFighting));
            }
            else
            {
                this.dispatchEvent(new EntityInfoEvent(EntityInfoEventName.RoleInFighting));
            }
            return;
        }// end function

        override public function updateSpeed(param1:int) : void
        {
            if (this._testSpeed)
            {
                this._serverSpeed = param1;
                return;
            }
            super.updateSpeed(param1);
            if (Global.isDebugModle)
            {
                MsgManager.showRollTipsMsg(Language.getStringByParam(20673, this.entityInfo.speed));
            }
            return;
        }// end function

        public function updateTestSpeed(param1:int) : void
        {
            this._testSpeed = param1;
            if (param1)
            {
                if (!this._serverSpeed)
                {
                    this._serverSpeed = entityInfo.speed;
                }
                super.updateSpeed(param1);
            }
            else if (this._serverSpeed)
            {
                super.updateSpeed(this._serverSpeed);
            }
            return;
        }// end function

        override public function updateBufferInfo(param1:SBuffInfo, param2:int) : void
        {
            super.updateBufferInfo(param1, param2);
            var _loc_3:* = BuffUtil.isCanRoleWalk();
            if (this._isCanControlWalk != _loc_3)
            {
                this._isCanControlWalk = _loc_3;
                if (!this._isCanControlWalk)
                {
                    AIManager.CancelAllTeamporary();
                }
            }
            return;
        }// end function

        override public function updateLife(param1:int, param2:Boolean = true) : void
        {
            super.updateLife(param1, param2);
            if (param1 == 0)
            {
                Log.debug("收到主角血量更新0");
            }
            return;
        }// end function

        override public function updateCareer(param1:int) : void
        {
            super.updateCareer(param1);
            Cache.instance.role.roleInfo.career = param1;
            Dispatcher.dispatchEvent(new DataEvent(EventName.RoleCareerChanged));
            return;
        }// end function

        override protected function reset() : void
        {
            super.reset();
            this._serverSpeed = 0;
            this._isCanControlWalk = true;
            return;
        }// end function

        public function get isCanControlWalk() : Boolean
        {
            return this._isCanControlWalk;
        }// end function

    }
}
